<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>

<head>
    <meta http-equiv="Content-Language" content="en-gb">
    <link rel="stylesheet" type="text/css" href="http://ant.apache.org/manual/stylesheets/style.css">
    <title>Jsonschema2Pojo Task</title>
</head>

<body>

    <h2><a name="taskname">Jsonschema2Pojo</a></h2>
    <h3>Description</h3>
    <p>jsonschema2pojo uses the structural rules present in a JSON Schema document to generate DTO style Java classes.</p>
    
    <h3>Parameters</h3>
    <table border="1" cellpadding="2" cellspacing="0">
      <tr>
        <td valign="top"><b>Attribute</b></td>
        <td valign="top"><b>Description</b></td>
        <td align="center" valign="top"><b>Required</b></td>
      </tr>
      <tr>
        <td valign="top">source</td>
        <td valign="top">The input JSON schema.</td>
        <td align="center" valign="top">Yes</td>
      </tr>
      <tr>
        <td valign="top">targetDirectory</td>
        <td valign="top">The directory that generated .java source files will be saved to.</td>
        <td align="center" valign="top">Yes</td>
      </tr>
      <tr>
        <td valign="top">targetPackage</td>
        <td valign="top">Package name used for generated Java classes (for types where a fully qualified name has not been supplied in the schema using the 'javaType' property).</td>
        <td align="center" valign="top">No</td>
      </tr>
      <tr>
        <td valign="top">generateBuilders</td>
        <td valign="top">Whether to generate builder-style methods of the form <code>withXxx(value)</code> (that return <code>this</code>), alongside the standard, void-return setters.</td>
        <td align="center" valign="top">No (default <code>false</code>)</td>
      </tr>
      <tr>
        <td valign="top">usePrimitives</td>
        <td valign="top">Whether to use primitives (<code>long</code>, <code>double</code>, <code>boolean</code>) instead of wrapper types where possible when generating bean properties (has the side-effect of making those.</td>
        <td align="center" valign="top">No (default <code>false</code>)</td>
      </tr>
      <tr>
        <td valign="top">skip</td>
        <td valign="top">Whether to skip type generation entirely (useful when set via a build property to allow quick disabling of this task using a command line property).</td>
        <td align="center" valign="top">No (default <code>false</code>)</td>
      </tr>
      <tr>
        <td valign="top">useLongIntegers</td>
        <td valign="top">Whether to use the java type <code>long</code> (or <code>Long</code>) instead of <code>int</code> (or <code>Integer</code>) when representing the JSON Schema type 'integer'.</td>
        <td align="center" valign="top">No (default <code>false</code>)</td>
      </tr>
      <tr>
        <td valign="top">propertyWordDelimiters</td>
        <td valign="top">A string containing any characters that should act as word delimiters when choosing Java bean property names.</td>
        <td align="center" valign="top">No (default none)</td>
      </tr>
      <tr>
        <td valign="top">includeHashcodeAndEquals</td>
        <td valign="top">Whether to use include <code>hashCode</code> and <code>equals</code> methods in generated Java types.</td>
        <td align="center" valign="top">No (default <code>true</code>)</td>
      </tr>
      <tr>
        <td valign="top">includeToString</td>
        <td valign="top">Whether to use include a <code>toString</code> method in generated Java types.</td>
        <td align="center" valign="top">No (default <code>true</code>)</td>
      </tr>
      <tr>
        <td valign="top">annotationStyle</td>
        <td valign="top">The style of annotations to use in the generated Java types. Supported values:
          <ul>
            <li><code>JACKSON2</code> (apply annotations from the <a href="https://github.com/FasterXML/jackson-annotations">Jackson 2.x</a> library)</li>
            <li><code>JACKSON1</code> (apply annotations from the <a href="http://jackson.codehaus.org/">Jackson 1.x</a> library)</li>
            <li><code>NONE</code> (apply no annotations at all)</li>
          </ul>
        </td>
        <td align="center" valign="top">No (default <code>JACKSON2</code>)</td>
      </tr>
      <tr>
        <td valign="top">includeJsr303Annotations</td>
        <td valign="top">Whether to include <a href="http://jcp.org/en/jsr/detail?id=303">JSR-303</a> annotations (for schema rules like minimum, maximum, etc) in generated Java types.
          <p>
          Schema rules and the annotation they produce:
          <ul>
            <li>maximum = <code>@DecimalMax</code>
            <li>minimum = <code>@DecimalMin</code>
            <li>minItems,maxItems = <code>@Size</code>
            <li>minLength,maxLength = <code>@Size</code>
            <li>pattern = <code>@Pattern</code>
            <li>required = <code>@NotNull</code>
          </ul>
          Any Java fields which are an object or array of objects will be annotated with <code>@Valid</code> to support validation of an entire document tree.
        </td>
        <td align="center" valign="top">No (default <code>false</code>)</td>
      </tr>
      <tr>
        <td valign="top">sourceType</td>
        <td valign="top">The type of input documents that will be read
          <p>
          Supported values:
          <ul>
            <li><code>JSONSCHEMA</code> (schema documents, containing formal rules that describe the structure of json data)</li>
            <li><code>JSON</code> (documents that represent an example of the kind of json data that the generated Java types will be mapped to)</li>
          </ul>
          </td>
          <td align="center" valign="top">No (default <code>JSONSCHEMA</code>)</td>
        </tr>
    </table>
        
    <h3>Examples</h3>
    <pre>
&lt;taskdef name="jsonschema2pojo" classname="com.googlecode.jsonschema2pojo.ant.Jsonschema2PojoTask">
    &lt;classpath> &lt;!-- classpath only required if jars have *NOT* been added to $ANT_HOME/lib -->
        &lt;fileset dir="my-downloaded-libs">
            &lt;include name="**/*.jar" />
        &lt;/fileset>
    &lt;/classpath>
&lt;/taskdef>

&lt;target name="generate">
    &lt;jsonschema2pojo source="address.json" 
                     targetDirectory="build/generated-types" 
                     targetPackage="com.example"/>
&lt;/target>
    </pre>
    The above uses the taskdef task to make the jsonschema2pojo task available. The generate target invokes the jsonschema2pojo task to generate java classes based on an input schema called <a href="http://json-schema.org/address">address.json</a>. 

</body>
</html>
